package com.zjj.learn.designmodel.principles.demo2.after;



/**
 * *** @author zjj_admin
 * *** 2022/4/4 23:33
 */
public class RectangleTest2 {

    public static void main(String[] args) {


        Rectangle rectangle = new Rectangle();
        rectangle.setLength(20);
        rectangle.setWidth(10);

        Square square = new Square();
        square.setSize(25);

        resize(rectangle);
        printLengthAndWidth(rectangle);

        System.out.println("===================");

        printLengthAndWidth(square);
    }




    //长方形扩宽操作
    public static void resize(Rectangle rectangle){
        while (rectangle.getWidth() <= rectangle.getLength()){
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    //打印长方形的长和宽
    public static void printLengthAndWidth(Quadrilateral quadrilateral){
        System.out.println("quadrilateral.getLength() = " + quadrilateral.getLength());
        System.out.println("quadrilateral.getWidth() = " + quadrilateral.getWidth());
    }
}
